package priv.ljh.operate.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import priv.ljh.operate.entity.Shopcar;
import priv.ljh.operate.service.ShopCarService;
import priv.ljh.operate.service.UserService;

import java.util.Date;
import java.util.List;

/**
 * @author ：Yshuaong
 * @date ：Created in 2021/6/14 14:06
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
public class ShopCarController {
    @Autowired
    ShopCarService shopCarService;

    @RequestMapping("/updateCar")
    public int updateCar(@RequestParam("number") int number, @RequestParam("sid") int sid){
        System.out.println("更新成功");
        return shopCarService.updateCar(number,sid);
    }
    @RequestMapping("/getAllcar")
    public List<Shopcar> getAllcar(@RequestParam("uid") int uid){
        System.out.println("购物车");
        List list1=shopCarService.getAllcar(uid);
        System.out.println(list1+"1111111111111");
        return shopCarService.getAllcar(uid);
    }
    @RequestMapping("/insertCar")
    public int insertCar(@RequestParam("title")String title,
                         @RequestParam("img_url") String img_url,
                         @RequestParam("sell_price") String sell_price, @RequestParam("market_price") String market_price,
                          @RequestParam("uid") int uid){
        System.out.println("插入成功");
        return shopCarService.insertCar(title,  img_url, sell_price, market_price, uid);
    }
    @RequestMapping("/deleteCar")
    public int deleteCar(@RequestParam("sid") int sid){
        System.out.println("删除成功");
        return shopCarService.deleteCar(sid);
    }
}
